<html>

	<head>
		<meta charset="UTF-8">
		<title>笔记详情</title>
		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/mooc.css">
	</head>
	<style>
		body {
			background: white;
		}
		
		.mui-title {
			color: white;
		}
		
		.mui-icon-left-nav {
			color: white;
		}
		
		.mui-content {
			background: white;
			height: 200px;
			;
		}
		
		.mui-bar.mui-bar-tab {
			background: white;
		}
		
		.savebtn {
			margin-top: 12px;
			font-size: 17px;
			color: white;
		}
		
		.resinfodiv {
			height: 45px;
			border-bottom: 1px solid #dddddd;
		}
		
		.restype-div {
			float: left;
			width: 60px;
			text-align: center;
			color: #fff;
			font-size: 13px;
			padding: 1px 2px 1px 2px;
			margin-left: 20px;
			margin-top: 11px;
		}
		
		.restype-div.sp {
			background: #4cc8e7;
		}
		
		.restype-div.jy {
			background: #ff9d34;
		}
		
		.restype-div.xt {
			background: #ff9d34;
		}
		
		.restype-div.st {
			background: #a5b9eb;
		}
		
		.restype-div.stjc {
			background: #799aed;
		}
		
		.restype-div.tp {
			background: #95c85d;
		}
		
		.restype-div.kj {
			background: #ff8873;
		}
		
		.resname-div {
			float: left;
			margin-left: 20px;
			margin-top: 11px;
		}
	</style>
     <input type="hidden" id="fStatus" value="0">
	<body>
		<header class="mui-bar mui-bar-nav headbar">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a><a id="savebtn" class="mui-pull-right savebtn">修改</a>
			<h1 class="mui-title" id='resnameh1'>笔记</h1>
		</header>
		<div class="mui-content">
			<div class="resinfodiv">
				<span id="rescat" class="restype-div sp"> </span><span id="restitle" class="resname-div"> </span>
			</div>
			<div class="mui-input-row" id="noteContent" style="margin:10px 5px 0px 20px;word-break: break-all; word-wrap:break-word;">
				
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../script/config.js"></script>
	<script type="text/javascript" src="../script/moocpublic.js"></script>
	<script src="../js/fastclick.js"></script>
	<script type="text/javascript" src="../js/DMobileFrame_DownLoadUtil.js"></script>
	<script>
	   var localStorageManagers=require('script/localStorageManagers.js');
		var downloadUtils = require('scripts/Core/DownLoadUtil.js');
		var mobileFrame=require('scripts/Core/MobileFrame.js');
		var courseid;
		var catalogid;
		var resid;
		var restitle;
		(function($) {
			//mui初始化
			mui.init({
				swipeBack: true
			});
			FastClick.attach(document.body);
			//plus初始化
			mui.plusReady(function() {
				
				 setNote();
				//var  rescatname = self.rescatname;
				//var preClass=getCatClass(rescatname);
				//var catEle=document.getElementById('rescat');
				//catEle.className='restype-div '+preClass;
				//catEle.innerText = rescatname;
				//setNote(courseid,catalogid,resid);
				//document.getElementById('restitle').innerHTML=restitle;
			});
			//保存笔记
			mui(document).on('tap', '#savebtn', saveNote);
			//输入框焦点
		})(mui);
		//获取笔记对象
		function setNote(){
			var self = plus.webview.currentWebview();
			var noteid = self.noteid;
			var rescatname=self.rescatname;
			var resname=self.resname;
			var notecontent=self.notecontent;
			document.getElementById('noteContent').innerHTML=notecontent;
			var preClass=getCatClass(rescatname);
			var catEle=document.getElementById('rescat');
			catEle.className='restype-div '+preClass;
			catEle.innerText = rescatname;
			document.getElementById('restitle').innerHTML=resname;
				   
			mui.ajax(serverAjax + "/mobile/note/findNote.do", {
				type: "post",
				dataType: 'json',
				data: {
					noteid:noteid
				},
				success: function(data) {
					if(data==null||data.length==0)return;
					document.getElementById('noteContent').innerHTML=data.noteContent;
					document.getElementById('fStatus').value=data.status;
					//var preClass=getCatClass(rescatname);
				   // var catEle=document.getElementById('rescat');
				    //catEle.className='restype-div '+preClass;
				    //catEle.innerText = rescatname;
				    //document.getElementById('restitle').innerHTML=resname;
				},
				error: function(xhr, type, errorThrown) {
					ajaxErrorTip();
					console.log(xhr);
				}
			});
		};
		//function setNoteContent(noteContent){
		//	document.getElementById('noteContent').innerHTML=noteContent;
		//}
		function setNoteContent(){
			var self = plus.webview.currentWebview();
			var noteid = self.noteid;
			//设置笔记内容
				mui.ajax(serverAjax + "/mobile/note/findNote.do", {
				type: "post",
				dataType: 'json',
				data: {
					noteid:noteid
				},
				success: function(data) {
					if(data==null||data.length==0)return;
					document.getElementById('noteContent').innerHTML=data.noteContent;
				},
				error: function(xhr, type, errorThrown) {
					ajaxErrorTip();
					console.log(xhr);
				}
				});
		};
		//打开修改笔记页面
		function saveNote() {
			
		    var self = plus.webview.currentWebview();
			var noteid = self.noteid;
			var rescatname=self.rescatname;
			var resname=self.resname;
			var notecontent=self.notecontent;
   mui.openWindow({
		url: 'updateNote.html',
		id: 'synccourse/updateNote',
		extras: {
			noteid: noteid,
			rescatname:rescatname,
			resname:resname,
			notecontent:notecontent
		}
	});
		}
		//获得资源类别显示背景色
		function getCatClass(preName) {
			var preClass = 'xt';
			switch (preName) {
				case "视频":
					preClass = 'sp';
					break;
				case "讲义":
					preClass = 'jy';
					break;
				case "习题":
					preClass = 'xt';
					break;
				case "教案":
					preClass = 'jy';
					break;
				case "随堂检测":
					preClass = 'stjc';
					break;
				default:
					preClass = 'xt';
			}
			return preClass;
		}
	</script>

</html>